#include"hashtable.h"
#include"unordered_set.h"
#include"unordered_map.h"
//void test1()
//{
//	openaddress::hashTable<int, int>myhash;
//	int arr[] = { 19,30,5,36,13,20,21,12,18,17 };
//	for (auto e : arr)
//		myhash.insert({ e,e });
//	int findaim = 1;
//	if (myhash.find(findaim))
//		cout << "success" << endl;
//	else
//		cout << "defeat" << endl;
//	int delaim = 17;
//	if (myhash.erase(delaim))
//		cout << "del success" << endl;
//	else
//		cout << "del defeat" << endl;
//	//myhash.show();
//
//}
//void test2()
//{
//	openaddress::hashTable<double, int>myhash;
//	int arr[] = { 19.12,30.12,5.21,36.32,1.3,2.0,2.1,1.322,1.8,17.189 ,17};
//	for (auto e : arr)
//		myhash.insert({ e,e });
//	double findaim = 17;
//	if (myhash.find(findaim))
//		cout << "success" << endl;
//	else
//		cout << "defeat" << endl;
//	double delaim = 17;
//	if (myhash.erase(delaim))
//		cout << "del success" << endl;
//	else
//		cout << "del defeat" << endl;
//	findaim = 17;
//	if (myhash.find(findaim))
//		cout << "success" << endl;
//	else
//		cout << "defeat" << endl;
//	//myhash.show();
//
//}
//
//struct func
//{
//	size_t operator()(const string& s)
//	{
//		return (size_t)*s.c_str();
//	}
//};

//void test3()
//{
//	openaddress::hashTable<string, string, func>myhash;
//	string arr[] = { "jyuju" ,"fwefw" ,"fregrg" };
//	for (auto& el : arr)
//		myhash.insert({ el ,el });
//	string findaim = "jyuju" ;
//	if (myhash.find(findaim))
//		cout << "success" << endl;
//	else
//		cout << "defeat" << endl;
//	string delaim = "jyuju";
//	if (myhash.erase(delaim))
//		cout << "del success" << endl;
//	else
//		cout << "del defeat" << endl;
//
//}
//
//void test4()
//{
//	hashbucket::HashTable<int, int>myhash1;
//	hashbucket::HashTable<int, int>myhash;
//	int arr[] = { 19,30 };
//	for (auto e : arr)
//		myhash1.insert({ e,e });
//	myhash = myhash1;
//	int in;
//	do
//	{
//		cout << "input the key:";
//		cin >> in;
//		if (myhash.find(in))
//			cout << "found it" << endl;
//		else
//			cout << "key don`t exist" << endl;
//	} while (in > 0);
//	do
//	{
//		cout << "input the delkey:";
//		cin >> in;
//		if (myhash.erase(in))
//			cout << "success" << endl;
//		else
//			cout << "key don`t exist" << endl;
//	} while (in > 0);
//	do
//	{
//		cout << "input the key:";
//		cin >> in;
//		if (myhash.find(in))
//			cout << "found it" << endl;
//		else
//			cout << "key don`t exist" << endl;
//	} while (in > 0);
//	cout << "----finish----" << endl;
//}
//
//void test5()
//{
//	hashbucket::HashTable<string, string, func>myhash1;
//	string arr[] = { "jyuju" ,"fwefw" ,"fregrg" };
//	for (auto& el : arr)
//		myhash1.insert({ el ,el });
//	hashbucket::HashTable<string, string, func>myhash(myhash1);
//	string findaim = "jyuju";
//	if (myhash.find(findaim))
//		cout << "success" << endl;
//	else
//		cout << "defeat" << endl;
//	string delaim = "jyuju";
//	if (myhash.erase(delaim))
//		cout << "del success" << endl;
//	else
//		cout << "del defeat" << endl;
//	findaim = "jyuju";
//	if (myhash.find(findaim))
//		cout << "success" << endl;
//	else
//		cout << "defeat" << endl;
//
//}

//struct func
//{
//	size_t operator()(const string& s)
//	{
//		return (size_t)*s.c_str();
//	}
//};
//void test5()
//{
//	egghead:: unordered_set<string,func>myhash1;
//	string arr[] = { "jyuju" ,"fwefw" ,"fregrg" };
//	for (auto& el : arr)
//		myhash1.insert(el);
//	egghead::unordered_set<string,func>myhash(myhash1);
//	string findaim = "jyuju";
//	if (myhash.find(findaim)._node)
//		cout << "success" << endl;
//	else
//		cout << "defeat" << endl;
//	string delaim = "jyuju";
//	if (myhash.erase(delaim))
//		cout << "del success" << endl;
//	else
//		cout << "del defeat" << endl;
//	findaim = "jyuju";
//	if (myhash.find(findaim)._node)
//		cout << "success" << endl;
//	else
//		cout << "defeat" << endl;
//
//}

struct func
{
	size_t operator()(const string& s)
	{
		return (size_t)*s.c_str();
	}
};
void test5()
{
	egghead::unordered_map<string, string, func>myhash1;
	string arr[] = { "jyuju" ,"fwefw" ,"fregrg" };
	for (const auto& el : arr)
		myhash1.insert({ el ,el });
	egghead::unordered_map<string, string, func>myhash(myhash1);
	string findaim = "jyuju";
	if (myhash.find(findaim)._node)
		cout << "success" << endl;
	else
		cout << "defeat" << endl;
	string delaim = "jyuju";
	if (myhash.erase(delaim))
		cout << "del success" << endl;
	else
		cout << "del defeat" << endl;
	if (myhash.find(findaim)._node)
		cout << "success" << endl;
	else
		cout << "defeat" << endl;
	myhash["jyuju"] = "jyuju";
	if (myhash.find(findaim)._node)
		cout << "success" << endl;
	else
		cout << "defeat" << endl;


}
int main()
{
	//test1();
	//test2();
	//test3();
	//test4();
	test5();
	return 0;
}